package com.old.people.service.serviceImp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.old.people.dao.ManagerMapper;
import com.old.people.entities.Account;
import com.old.people.entities.DieasePeople;

@Service
public class ManagerServiceImp implements com.old.people.service.ManagerService {
	@Autowired
	private ManagerMapper managerMapper;
//账号管理
	@Override
	public List<Account> accountManager(int page) {
		int sum=managerMapper.getAccountSum();
		int begin=page*10-10;
		if(begin<0) {
			begin=0;
		}
		return managerMapper.getAccount(begin);
	}

	@Override
	public int accountSum() {
		int sum=(int)managerMapper.getAccountSum();
		int page=0;
		if(sum%10>0) {
			page=sum/10+1;
		}else {
			page=sum/10;
		}
		return page;
	}

	@Override
	public boolean updateAccountType(String account_id, String account_type) {
		return managerMapper.updateAccountType(account_id, account_type);
	}

	@Override
	public Account selectAccount(String account_id) {
		return managerMapper.selectAccount(account_id);
	}
//老人疾病查看
	@Override
	public List<DieasePeople> getDieasePeople(Integer page) {
		int sum=managerMapper.getDieasePeopleSum();
		int begin=page*10-10;
		if(begin<0) {
			begin=0;
		}
		return managerMapper.getDieasePeople(begin);
	}

	@Override
	public Integer getDieasePeopleSum() {
		int sum=(int)managerMapper.getDieasePeopleSum();
		int page=0;
		if(sum%10>0) {
			page=sum/10+1;
		}else {
			page=sum/10;
		}
		return page;
	}

	@Override
	public List<DieasePeople> selectDieasepeople(String oldpeople_name) {
		return managerMapper.selectDieasepeople(oldpeople_name);
	}
//个人信息修改
	@Override
	public boolean updateAccount(String account_id, String account_password) {
		return managerMapper.updateAccount(account_id, account_password);
	}
}
